package com.xwj.dao.database2;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

/**
 * @author xwj
 * @date 2020/12/11
 */
@Mapper
@Repository
public interface StorageMapper {
    /**
     * 减少库存
     *
     * @param productId
     * @param count
     * @return
     */
    @Update("update storage set used = used + #{count},residue = residue - #{count} where product_id = #{productId} and residue >= #{count}")
    int decrease(@Param("productId") Long productId, @Param("count") Integer count);
}
